#!/usr/bin/python

class source(object):
	
	def __init__(self, null):
		import gdata.youtube, gdata.youtube.service
		from subprocess import call
				
		yt_service = gdata.youtube.service.YouTubeService()
		query = gdata.youtube.service.YouTubeVideoQuery()
		query.racy = 'include'
		
	def retrieve(self, title, audioformat):
		query.vq = title
		results = yt_service.YouTubeQuery(query)
		url = feed.entry[0].GetSwfUrl()
		call(['./youtube-dl.py', '--extract-audio', '--audio-format', audioformat, '-q', '-f', '34', '-w', '-o', title, url])
